//
//  ViewController.m
//  03-17-hitTest2Demo
//
//  Created by student on 16/3/17.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"
#import "MyButton.h"
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *button;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)btnPressed:(MyButton *)sender {
    
    if (sender.button!=nil) {
        [sender.button removeFromSuperview];
    }
    else{
    
    UIButton *btn=[[UIButton alloc]init];
    
    //大小
    btn.bounds=CGRectMake(0, 0, 200, 200);
    //中心点
    btn.center=CGPointMake(100, -100);
    
    [btn setBackgroundImage:[UIImage imageNamed:@"对话框"] forState:UIControlStateNormal];
    
    [btn setBackgroundImage:[UIImage imageNamed:@"小孩"] forState:UIControlStateHighlighted];
    
    [sender addSubview:btn];
        
        sender.button=btn;
        
    }
    
    
}


@end
